| 
                
               | 
              
                
               | 
              
                @@ -581,9 +581,15 @@ def statistic_coupon(request): 
               | 
            
            
            
              | 
                581
               | 
              
                581
               | 
              
                  
               | 
            
            
            
              | 
                582
               | 
              
                582
               | 
              
                     froms_logs = list(coupons.values('coupon_from').annotate(num=Count('user_coupon_id')))
               | 
            
            
            
              | 
                583
               | 
              
                583
               | 
              
                     type_logs = list(coupons.values('coupon_title', 'coupon_value').annotate(num=Count('user_coupon_id')))
               | 
            
            
            
              | 
                584
               | 
              
                
               | 
              
                -    type_has_used_logs = list(coupons.filter(has_used=True).values('coupon_title', 'coupon_value').annotate(num=Count('user_coupon_id')))
               | 
            
            
            
              | 
                
               | 
              
                584
               | 
              
                + 
               | 
            
            
            
              | 
                
               | 
              
                585
               | 
              
                +    if start_time and end_time: 
               | 
            
            
            
              | 
                
               | 
              
                586
               | 
              
                +        used_coupons = UserCouponInfo.objects.filter(used_at__range=(start_time, end_time), status=True) 
               | 
            
            
            
              | 
                
               | 
              
                587
               | 
              
                +    else: 
               | 
            
            
            
              | 
                
               | 
              
                588
               | 
              
                +        used_coupons = UserCouponInfo.objects.filter(status=True) 
               | 
            
            
            
              | 
                
               | 
              
                589
               | 
              
                + 
               | 
            
            
            
              | 
                
               | 
              
                590
               | 
              
                +    type_has_used_logs = list(used_coupons.values('coupon_title', 'coupon_value').annotate(num=Count('user_coupon_id')))
               | 
            
            
            
              | 
                585
               | 
              
                591
               | 
              
                      
               | 
            
            
            
              | 
                586
               | 
              
                
               | 
              
                -    return response(200, 'Get Consumer Statistic Success', u'获取消费者统计成功', data={
               | 
            
            
            
              | 
                
               | 
              
                592
               | 
              
                +    return response(200, 'Get Consumer Statistic Success', u'获取用户劵统计成功', data={
               | 
            
            
            
              | 
                587
               | 
              
                593
               | 
              
                         'froms_logs': froms_logs, 
               | 
            
            
            
              | 
                588
               | 
              
                594
               | 
              
                         'type_logs': type_logs, 
               | 
            
            
            
              | 
                589
               | 
              
                595
               | 
              
                         'type_has_used_logs': type_has_used_logs, 
               |